package com.myself.hello.web.dao;

import com.myself.hello.web.dataobject.ZhangkeruiAccountingRecord;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
@Mapper
public interface ZhangkeruiAccountingRecordMapper {
    @Delete({
        "delete from zhangkerui_accounting_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into zhangkerui_accounting_record (record_type, ",
        "desc, amount, record_time, ",
        "category, now() ",
        "now())",
        "values ( #{recordType,jdbcType=VARCHAR}, ",
        "#{desc,jdbcType=VARCHAR}, #{amount,jdbcType=DOUBLE}, #{recordTime,jdbcType=TIMESTAMP}, ",
        "#{category,jdbcType=VARCHAR}, #{gmtCreated,jdbcType=TIMESTAMP}, ",
        "#{gmtModified,jdbcType=TIMESTAMP})"
    })
    int insert(ZhangkeruiAccountingRecord record);

    @Select({
        "select",
        "id, record_type, desc, amount, record_time, category, gmt_created, gmt_modified",
        "from zhangkerui_accounting_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="record_type", property="recordType", jdbcType=JdbcType.VARCHAR),
        @Result(column="desc", property="desc", jdbcType=JdbcType.VARCHAR),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DOUBLE),
        @Result(column="record_time", property="recordTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="category", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP)
    })
    ZhangkeruiAccountingRecord selectByPrimaryKey(Long id);

    @Select({
        "select",
        "id, record_type, desc, amount, record_time, category, gmt_created, gmt_modified",
        "from zhangkerui_accounting_record"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="record_type", property="recordType", jdbcType=JdbcType.VARCHAR),
        @Result(column="desc", property="desc", jdbcType=JdbcType.VARCHAR),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DOUBLE),
        @Result(column="record_time", property="recordTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="category", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP)
    })
    List<ZhangkeruiAccountingRecord> selectAll();

    @Update({
        "update zhangkerui_accounting_record",
        "set record_type = #{recordType,jdbcType=VARCHAR},",
          "desc = #{desc,jdbcType=VARCHAR},",
          "amount = #{amount,jdbcType=DOUBLE},",
          "record_time = #{recordTime,jdbcType=TIMESTAMP},",
          "category = #{category,jdbcType=VARCHAR},",
          "gmt_created = #{gmtCreated,jdbcType=TIMESTAMP},",
          "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(ZhangkeruiAccountingRecord record);
}